import requests
import random

def get_links():
    with open("links.log","r") as f:
        links = [x for x in f.read().split("\n") if len(x)>1]
        random.shuffle(links)
        return links

def connect(url,timeout=3):
    try:
        print("trying to reach {}".format(url))
        requests.get(url,timeout=timeout)
        print("request succeed!")
    except:
        print("request timeout.")

if __name__ == "__main__":
    links = get_links()
    for link in links:
        connect(link)
